
require(['./config'], () => {
    require(['template','header', 'footer','area','select','calendar'], (template) => {
        class pay{
            constructor(){
                this.init()
                this.data()
            }
            data(){
                $('#dd').calendar({
                    trigger: '#dt',
                    zIndex: 999,
                    format: 'yyyy-mm-dd',
                    onSelected: function (view, date, data) {
                        console.log('event: onSelected')
                    },
                    onClose: function (view, date, data) {
                        console.log('event: onClose')
                        console.log('view:' + view)
                        console.log('date:' + date)
                        console.log('data:' + (data || 'None'));
                    }
                });
            }
            init(){
                let cartList = localStorage.getItem('cart')
                this.shop=JSON.parse(cartList);
                let list=this.shop.filter(cart=>{
                    return cart.check===true
                })
                if(list){
                    $('#order-detail').html(template('order',{list}))
                    var totalMoney=0
                    for(var i=0;i<list.length;i++){
                       totalMoney+=list[i].price*list[i].num
                    }
                    $('.total').html(totalMoney.toFixed(2))
                    this.end()
                }else{
                    alert('当前还未选择商品，请前往购物车选择要支付的商品')
                    window.location.href = '/html/shopping.html'
                }
            }
            end(){
                $('.submit-order').on('click',function(){
                   $('.code').show()
                })
            }
        }
        new pay()

      
    })
  })